class FileListPlugin {
  constructor(options) {}
  apply(compiler) {
    compiler.hooks.emit.tapAsync('MyExampleWebpackPlugin', (compilation, callback) => {
      let filelist = '打包后的文件列表:\n\n';
      for (let filename in compilation.assets) {
        filelist += '-' + filename + '\n';
      }
      compilation.assets['fileList.txt'] = {
        source: function () {
          return filelist;
        },
        size: function () {
          return filelist.length;
        }
      };
      callback();
    });
  }
}

module.exports = FileListPlugin;
